// axios二次封装
import http from '../request/http'

// 登录
const login =(pats)=>{
    return http.post('login',pats)
}

//用户数据
const user = (user)=>{
    return http.get(`users?query=${user.query}&pagesize=${user.pagesize}&pagenum=${user.pagenum}`)
}

// 用户添加
const addus = (add)=>{
    return http.post('users',add)
}

// 用户状态修改
const revise = (ris)=>{
    return http.put(`users/${ris.id}/state/${ris.type}`)
}

// 用户数据修改
const edits = (dit)=>{
    return http.put(`users/${dit.id}`,{email:dit.email,mibile:dit.mobile})
}

// 用户信息查询
const sear = (serch)=>{
    return http.get(`users/${serch.id}`)
}

// 用户信息删除
const del = (dels)=>{
    return http.delete(`users/${dels.id}`)
}

// 用户分配  (未完成)+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
const role = (rle)=>{
    return http.put(`users/${rle}/role`)
}

// 角色列表
const rol =(ol)=>{
    return http.get('roles',ol)
}

// 角色列表
const Permissions = ()=>{
    return http.get('roles')
}



// 添加角色
const addrl=(nameRol)=>{
    return http.post('roles',nameRol)
}

// 根据id查询角色=============================(未完成)
// const rolId = (Rd)=>{
//     return http.get('roles/')
// }

// 编辑提交角色
const Editrold = (Eld)=>{
    return http.put(`roles/${Eld.id}`,Eld)
}

// 删除角色
const Del = (Dl)=>{
    return http.delete(`roles/${Dl.id}`)
}

// 商品列表数据
const cartList = (ct)=>{
    return http.get(`goods?query=${ct.query}&pagenum=${ct.pagenum}&pagesize=${ct.pagesize}`)
}

// 添加商品 ++++++++++++++++++++++++++++++++++++++++++++++(未完成)
const addCommodity = (aty)=>{
    return http.post('goods',aty)
}

// 修改商品
const editComdity = (sear)=>{
    return http.put(`goods/${sear.goods_id}`,sear)
}

// 删除商品
const delComdity = (del)=>{
    return http.delete(`goods/${del.id}`)
}

// 商品分类数据列表
const cartlist = (lis)=>{
    return http.get('categories',lis)
}

// 商品列表渲染
const cartts = (ats)=>{
    return http.get(`categories/${ats.id}/attributes`,ats)
}
// 商品添加
const addCart = (act)=>{
    return http.post(`categories/${act.id}/attributes`,act)
}

// 商品删除
const cartDel = (cdl)=>{
    return http.delete(`categories/${cdl.cat_id}/attributes/${cdl.attr_id}`)
}

// 商品修改
const cartEdit = (cet)=>{
    return http.put(`categories/${cet.id}/attributes/${cet.attrId}`,cet)
}

//添加分类
const addIfy = (adfy)=>{
    return http.post(`categories`,adfy)
}

// 订单数据列表
const ordersList = (orDer)=>{
    return http.get(`orders`,orDer)
}

// 折线图数据统计
const imglist = (ils)=>{
    return http.get('reports/type/1')
}

// 权限列表============================================
const prmion=(val)=>{
    return http.get(`rights/${val}`)
}
//角色授权
const roles=(Rls)=>{
    return http.post(`roles/${Rls.roleId}/rights`,Rls)
}



// 删除角色权限
const rolesPom = (row,ROle)=>{
    return http.delete(`roles/${row.id}/rights/${ROle.id}`)
}

// 上传图片
const upload = (obj)=>{
    return http.post('upload',obj)
}

// 添加标签
const addl = ()=>{
    return http.put(`categories/:id/attributes/:attrId`)
}
export {login,user,addus
    ,revise,edits,sear,del,role,rol,Permissions,prmion,
    addrl,Editrold,Del,rolesPom,cartList,addCommodity,editComdity
    ,delComdity,cartlist,addCart,cartts,cartDel,cartEdit,addIfy,
    ordersList,imglist,roles,upload,addl
}